<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>荣誉证书模版</title>
    <style>
        @font-face {
            font-family: 'MyCustomFont';
            src: url('../font/MyFont-pen.ttf') format('woff2'),
                 url('../font/MyFont-pen.ttf') format('woff'),
                 url('../font/MyFont-pen.ttf') format('truetype');
            font-weight: normal;
            font-style: normal;
        }
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: #fff;
            display: flex;
            justify-content: center;
            align-content: center;
            height: 90vh;
            flex-wrap: wrap;
        }
        
        .certificate-container {
            background: url(../img/bg_honor.png) no-repeat 0 0;
            background-size: 100%;
            padding: 20px;
            background-color: #fffdf9;
            height: 85%;
        }
        
        .honor-certificate {
            width: 800px;
            padding: 60px;
            position: relative;
        }
        
        .header {
            text-align: center;
            position: relative;
        }
        
        .title {
            font-size: 42px;
            font-weight: bold;
            margin-bottom: 30px;
            color: #d4a637;
            letter-spacing: 10px;
            text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.1);
            display: flex;
            justify-content: center;
        }

        .title:before, .title:after {
            content: "";
            display: block;
            width: 20%;
            height: 15px;
            background: linear-gradient(90deg, transparent, #d4a637, transparent);
            margin: 20px 0;
            opacity: 0.6;
        }

        .content {
            font-size: 20px;
            line-height: 2.5;
            color: #333;
            margin: 0 auto;
        }
        
        .footer {
            margin-top: 60px;
            text-align: center;
            line-height: 2;
            font-size: 18px;
            position: relative;
            margin-left: 40%;
        }
        
        .award-date {
            text-align: center;
            margin: 30px 0;
            font-size: 18px;
        }
        
        .editable {
            border-bottom: 1px solid #d4a637;
            min-width: 100px;
            display: inline-block;
            margin: 0 10px 0 10px;
            text-align: center;
            text-indent: 0;
        }
        
        .editable.placeholder {
            color: #999;
        }
        
        .print-btn {
            padding: 10px 20px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-family: 'SimSun', serif;
            font-size: 16px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            transition: all 0.3s;
            margin-top: 10px;
        }

        .signature-btn {
            padding: 10px 20px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-family: 'SimSun', serif;
            font-size: 16px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            transition: all 0.3s;
        }
        
        .print-btn:hover {
            background-color: #d4a637;
            transform: translateY(-2px);
        }

        .signature-btn:hover {
            background-color: #d4a637;
            transform: translateY(-2px);
        }

        .signature-pad {
            position: fixed;
            top: 50%;
            right: 30px;
            display: flex;
            flex-direction: column;
        }

        .signature-image {
            max-height: 150px;
            position: absolute;
            right: 0;
            bottom: 0;
            margin-right: 120px;
        }

        .seal-image {
            max-height: 150px;
            position: absolute;
            right: 0;
            bottom: 0;
            margin-right: 120px;
        }

        .modal {
            display: none;
            position: fixed;
            z-index: 100;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0,0,0,0.7);
        }

        .modal-content {
            background-color: #fefefe;
            margin: 10% auto;
            padding: 30px;
            border: 1px solid #888;
            width: 50%;
            max-width: 500px;
            border-radius: 8px;
            text-align: center;
            box-shadow: 0 5px 15px rgba(0,0,0,0.3);
        }

        .close {
            color: #aaa;
            float: right;
            font-size: 28px;
            font-weight: bold;
            cursor: pointer;
        }

        .close:hover {
            color: black;
        }

        .file-upload-container {
            margin: 30px 0;
            padding: 20px;
            border: 2px dashed #d4a637;
            border-radius: 8px;
            background-color: #fffdf9;
            transition: all 0.3s;
        }

        .file-upload-container:hover {
            border-color: #b38f2e;
            background-color: #fff9f0;
        }


        .file-upload-btn {
            position: relative;
            overflow: hidden;
            display: inline-block;
            padding: 12px 24px;
            background: linear-gradient(135deg, #e6b741 0%, #d4a637 100%);
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            transition: all 0.3s;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        }

        .file-upload-btn:hover {
            background: linear-gradient(135deg, #d4a637 0%, #c3962f 100%);
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0,0,0,0.15);
        }

        .file-upload-input {
            position: absolute;
            font-size: 100px;
            opacity: 0;
            right: 0;
            top: 0;
            cursor: pointer;
        }

        .file-name {
            margin-top: 10px;
            font-size: 14px;
            color: #666;
            font-style: italic;
        }

        .upload-btn {
            margin: 20px auto;
            padding: 12px 30px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            display: block;
            transition: all 0.3s;
        }

        .upload-btn:hover {
            background: linear-gradient(135deg, #5a6fd1 0%, #6a4299 100%);
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0,0,0,0.15);
        }

        .upload-btn:disabled {
            background: #ccc;
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
        }


        @media print {
            .print-btn, .signature-pad {
                display: none;
            }
            body {
                background-image: none;
            }
        }
    </style>
</head>
<body>
    <div class="certificate-container">
        <div class="honor-certificate">
            <div class="header">
                <div class="title">荣 誉 证 书</div>
            </div>
            
            <div class="content">
                <span class="editable placeholder" contenteditable="true" data-placeholder="（请输入姓名）" style="font-family: 'MyCustomFont';font-size: 28px;"></span>先生/女士：
            </div>
            
            <div class="content" style="margin-top: 20px;text-indent: 4rem;">
                在<span class="editable placeholder" contenteditable="true" data-placeholder="（请输入领域/活动）" style="font-family: 'MyCustomFont';"></span>中被评为<span class="editable placeholder" contenteditable="true" data-placeholder="（请输入奖项/称号）" style="font-family: 'MyCustomFont';font-size: 30px;color: red;"></span>
            </div>
            
            <div class="content" style="margin-top: 20px;text-indent: 4rem;font-size:22px;font-weight: 600;">
                特发此证，以资鼓励
            </div>
            
            <div class="footer">
                <div>颁发单位：<span class="editable signature-field" contenteditable="true" data-placeholder="（请输入颁发单位）"></span></div>
                <div>证书编号：<span class="editable placeholder" contenteditable="true" data-placeholder="（请输入证书编号）"></span></div>
                <img id="sealImg" class="seal-image" style="display: none;">
                <div>颁发日期：<span class="editable placeholder" contenteditable="true" data-placeholder="（请输入颁发日期）"></span></div>
            </div>
        </div>
    </div>

    <div class="signature-pad">
        <button class="signature-btn" onclick="openSignatureModal()">签章</button>
        <button class="print-btn" onclick="window.print()">打印</button>
    </div>

    <!-- 印章模态框 -->
    <div id="signatureModal" class="modal">
        <div class="modal-content">
            <span class="close" onclick="closeSignatureModal()">&times;</span>
            <h2>选择印章图片</h2>
            <div class="file-upload-container">
                <button class="file-upload-btn">
                    选择文件
                    <input type="file" id="signatureUpload" class="file-upload-input" accept="image/*">
                </button>
                <div id="fileName" class="file-name">未选择文件</div>
            </div>
            <button id="uploadBtn" class="upload-btn" onclick="uploadSignature()" disabled>确认</button>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const editables = document.querySelectorAll('.editable');
            
            editables.forEach(editable => {
                const placeholder = editable.getAttribute('data-placeholder');
                if (placeholder) {
                    if (!editable.textContent.trim()) {
                        editable.textContent = placeholder;
                        editable.classList.add('placeholder');
                    }
                    
                    editable.addEventListener('focus', function() {
                        if (this.classList.contains('placeholder')) {
                            this.textContent = '';
                            this.classList.remove('placeholder');
                        }
                    });
                    
                    editable.addEventListener('blur', function() {
                        if (!this.textContent.trim()) {
                            this.textContent = placeholder;
                            this.classList.add('placeholder');
                        }
                    });
                }
            });

            // 文件选择变化时更新显示
            document.getElementById('signatureUpload').addEventListener('change', function(e) {
                const fileNameDisplay = document.getElementById('fileName');
                const uploadBtn = document.getElementById('uploadBtn');
                
                if (this.files.length > 0) {
                    fileNameDisplay.textContent = this.files[0].name;
                    uploadBtn.disabled = false;
                } else {
                    fileNameDisplay.textContent = '未选择文件';
                    uploadBtn.disabled = true;
                }
            });
        });

        // 打开印章模态框
        function openSignatureModal() {
            document.getElementById('signatureModal').style.display = 'block';
        }

        // 关闭印章模态框
        function closeSignatureModal() {
            document.getElementById('signatureModal').style.display = 'none';
        }

        // 选择印章图片
        function uploadSignature() {
            const fileInput = document.getElementById('signatureUpload');
            const reader = new FileReader();
            reader.onload = function(e) {
                const sealImg = document.getElementById('sealImg');
                sealImg.src = e.target.result;
                sealImg.style.display = 'block';
                closeSignatureModal();
                
                // 重置文件选择
                fileInput.value = '';
                document.getElementById('fileName').textContent = '未选择文件';
                document.getElementById('uploadBtn').disabled = true;
            };
            reader.readAsDataURL(fileInput.files[0]);
        }
    </script>
</body>
</html>